// less
require('./components/bootstrap/bootstrap.less');
require('./assets/less/common.less');
// css
import 'vue-beauty/package/style/vue-beauty.min.css'
// npm depend on
import Vue from 'vue';
import VueResource from 'vue-resource';
import VueValidator from 'vue-validator';
import Vuex from 'vuex';
import "babel-polyfill";
//noinspection JSUnresolvedVariable
import WohomeApp from './wohome-app.vue';
import getRouterInstance from './wohome-router';
import store from './vuex/store';
import * as filter from './filter';
import * as verification from './verification';
import * as utils from './utils/tool'
import vueBeauty from 'vue-beauty'
import VideoPlayer from 'vue-video-player'
import axios from 'axios'
import iView from 'iview';
import 'iview/dist/styles/iview.css';
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-default/index.css'


Vue.use(VideoPlayer)
Vue.use(vueBeauty)
Vue.use(VueResource);
Vue.use(VueValidator);
Vue.use(Vuex);
Vue.use(ElementUI);
Vue.use(iView);
Vue.prototype.$ajax = axios

Vue.prototype.$utils = utils
//设置为非测试状态时，覆写console.debug,使其不打印debug信息
var debug=true;//配置是否打印debug信息
if(!debug){
  window.console.debug=function () {
  }
}

//注册vue的过滤器
Object.keys(filter).forEach(k=>Vue.filter(k, filter[k]));
//注册自定义的验证规则
Object.keys(verification).forEach(k=>Vue.validator(k, verification[k]));

var app = Vue.extend({
  store: store,
  components: {WohomeApp},
});

let router = getRouterInstance();
//认证验证，页面需要实名认证而未认证的情况
router.beforeEach((transition) => {
  //不存在accessToken 说明未登录过
  if (transition.to.path!='/login' && !store.state.token.accessToken) {
    transition.redirect('/login');
    return;
  }
  transition.next();
});
router.start(app, 'body');
console.log('router', router)
store.state.router = router
